#pragma once
#include <string>
#include <memory>
#include "logging.h"
#include "sqlite_orm/sqlite_orm.h"

struct Student {
    long studentId;
    std::string name;
    int age;
};

inline auto init_storage(const std::string &file_name) {
    return sqlite_orm::make_storage(
        file_name,
        sqlite_orm::make_table("students",
                               sqlite_orm::make_column("student_number", &Student::studentId,
                                                       sqlite_orm::primary_key()),
                               sqlite_orm::make_column("name", &Student::name, sqlite_orm::not_null()),
                               sqlite_orm::make_column("age", &Student::age))
    );
}

namespace storage {
    using storage_t = decltype(init_storage(""));

    class StorageProxy {
    public:
        explicit StorageProxy(const std::string &file_name,const std::string&);

        int insert_info(const Student &student_info) const;

        auto get_info_by_studentId(long studentId) const;

        auto get_all_pointer() const;

        auto delete_by_studentId(long studentId) const;

    private:
        std::string file_name_;
        std::string passwd_;
        std::unique_ptr<storage_t> storage_;
    };
}
